package com.hmall.item.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * @Author: zhuan
 * @Desc: MP-配置类
 * @Date: 2022-05-06 12:01:14
 */
@Configuration
public class MybatisPlusConfig {
    /**
	 * 功能描述:  配置Mybatis-Plus核心拦截器
	 * @return : com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor
	 */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        //1.定义MybatisPlus核心拦截器-MybatisPlusInterceptor
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //2.定义分页拦截器
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        //3.把分页拦截器添加到核心拦截器链中
        mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        return mybatisPlusInterceptor;
    }
}